1. Technical Field
The present invention is generally directed to an improved computer code optimization apparatus and method. More specifically, the present invention is directed to an apparatus and method for removing stores to local variables that are not aliased by other variables.
2. Description of Related Art
Dead store elimination (DSE) is a common optimization tool for compilers when compiling instructions. DSE is used to remove store instructions, or “stores,” to memory that are no longer necessary. For example, compiler optimizations such as constant propagation, which propagates constant values forward in compiled code, often result in opportunities for store elimination. Such compiler optimizations permit the removal of code for such store operations if, after the constant propagation, the compiler can determine that the variable subject of the store operation is not subsequently used. Removing the code for such a store operation reduces execution path length in the compiled computer code.
While DSE is a useful optimization mechanism, it may greatly increase the compilation time for instructions. For example, the time it takes for DSE to optimize the instructions for a procedure is a function of the number of memory references in the procedure squared, i.e. O(memoryReferences^2). In addition, the amount of memory space needed to perform the DSE operation for a procedure is also a function of the number of memory references in the procedure squared, i.e. O(memoryReferences^2).
For procedures with many memory references, the memory requirements can be too large to represent the entire procedure in the available memory. Therefore, DSE may not be able to run on some procedures in source code. This leads to longer execution paths and thus, longer execution times. In addition, the compile time spent performing DSE operations may amount to a large percentage of the compile time at high optimization levels.
Therefore, it would be beneficial to have an apparatus and method for improving upon DSE mechanisms so that the memory requirements and execution times for performing the DSE operations are reduced.